package com.ruoyi.novel.controller;

import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.novel.domain.Directory;
import com.ruoyi.novel.domain.Read;
import com.ruoyi.novel.service.ReadService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 阅读小说相关接口
 */
@RestController
@RequestMapping("/read")
public class ReadController extends BaseController {
    @Autowired
    private ReadService readService;
    /**
     * 根据书名获取小说内容
     */
    @GetMapping("/getNovelContent")
    public AjaxResult getNovelContent(@RequestParam String title){
        Read read = readService.getNovelContent(title);
        return success(read);
    }
    /**
     * 查询小说的章节信息
     */
    @RequestMapping("/getNovelChapter")
    public TableDataInfo getNovelChapter(@RequestParam String title){
        List<Directory> directory =  readService.getNovelChapter(title);
        return getDataTable(directory);
    }
    /**
     * 签约
     */
    @PostMapping("/sign")
    public AjaxResult sign(@RequestParam("UserId") Long UserId){
        return AjaxResult.success(readService.sign(UserId)) ;
    }
}
